#!/bin/ash

if [ -z "$TZ" ]; then
  echo "Info: Please configure timezone (env TZ), defaulting to UTC"
  echo "Info: See supported environment variables https://hub.docker.com/r/phpipam/phpipam-www"
  export TZ="UTC"
fi


if [ -f /usr/share/zoneinfo/$TZ ]; then
  echo "Info: Setting timezone to $TZ"
  setup-timezone -z $TZ
  echo -e "[Date]\ndate.timezone = $TZ" >/etc/php83/conf.d/99_tz.ini
  exit 0
else
  echo "Error: Timezone TZ=\"$TZ\" not found in /usr/share/zoneinfo"
  echo "Info: See supported environment variables https://hub.docker.com/r/phpipam/phpipam-www"
  exit 1
fi
